{$A+,B-,D-,E-,F-,G+,I-,L-,N-,O-,R-,S-,V-,X-}

program ColorBars;

uses Crt, Graph;


var     c        : byte;
        c2,c3,c4 : word;
        sintab   : array [0..127] of word;
        headptr:word absolute $40:$1A;
        tailptr:word absolute $40:$1C;
        GraphDriver, GraphMode: integer;

begin
  DetectGraph(GraphDriver, GraphMode);
  ClrScr;
  if (GraphDriver<>EGA) and (GraphDriver<>VGA) then
  begin
    writeln ('Sorry, you need a EGA or VGA adaptor to run this program...');
    halt;
  end;

    for c:=0 to 127 do
      sintab[c]:=trunc((sin((2*pi/128)*c)+1)*135);
    c3:=100;
    repeat
      if GraphDriver=VGA then
      begin
      inline($FA);
      repeat until (port[$3DA] and 8)>0;
      repeat until (port[$3DA] and 8)=0;
      for c4:=0 to sintab[c3 and 127] do begin
        repeat until (port[$3DA] and 1)=0;
        repeat until (port[$3DA] and 1)>0;
      end;
      for c:=15 to 31 do begin
        repeat until (port[$3DA] and 1)>0;
        port[$3C8]:=0; {moet 0 blijven}
        port[$3C9]:=C;
        port[$3C9]:=0;
        port[$3C9]:=C;
        repeat until (port[$3DA] and 1)=0;
      end;
      for c:=31 downto 15 do begin
        repeat until (port[$3DA] and 1)>0;
        port[$3C8]:=0; {moet 0 blijven}
        port[$3C9]:=C;
        port[$3C9]:=0;
        port[$3C9]:=C;
        repeat until (port[$3DA] and 1)=0;
      end;
      for c:=15 to 31 do begin
        repeat until (port[$3DA] and 1)>0;
        port[$3C8]:=0; {moet 0 blijven}
        port[$3C9]:=0;
        port[$3C9]:=C;
        port[$3C9]:=0;
        repeat until (port[$3DA] and 1)=0;
      end;
      for c:=31 downto 15 do begin
        repeat until (port[$3DA] and 1)>0;
        port[$3C8]:=0; {moet 0 blijven}
        port[$3C9]:=0;
        port[$3C9]:=C;
        port[$3C9]:=0;
        repeat until (port[$3DA] and 1)=0;
      end;
      for c:=15 to 31 do begin
        repeat until (port[$3DA] and 1)>0;
        port[$3C8]:=0; {moet 0 blijven}
        port[$3C9]:=C;
        port[$3C9]:=0;
        port[$3C9]:=0;
        repeat until (port[$3DA] and 1)=0;
      end;
      for c:=31 downto 15 do begin
        repeat until (port[$3DA] and 1)>0;
        port[$3C8]:=0; {moet 0 blijven}
        port[$3C9]:=C;
        port[$3C9]:=0;
        port[$3C9]:=0;
        repeat until (port[$3DA] and 1)=0;
      end;

      port[$3C8]:=0;
      port[$3C9]:=0;port[$3C9]:=0;port[$3C9]:=0;
      inc(c3);
      inline($FB);
    end;
    until headptr<>tailptr;
   headptr:=tailptr;
   ClrScr;
   writeln ('Have a nice DOS...');
end.